package me.jessyan.mvparms.demo.mvp.ui.activity.auth;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import me.jessyan.mvparms.demo.R;
import me.jessyan.mvparms.demo.mvp.ui.widget.CustomToolbar;

public class AuthResultActivity extends BaseActivity {
    boolean isSuccess = false;

    @BindView(R.id.toolbar)
    CustomToolbar toolbar;
    @BindView(R.id.result_iv)
    ImageView resultIv;
    @BindView(R.id.result_tv)
    TextView resultTv;
    @BindView(R.id.notice_tv)
    TextView noticeTv;
    @BindView(R.id.back_tv)
    TextView backTv;


    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        isSuccess = getIntent().getBooleanExtra("type", false);
    }

    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_auth_result;
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {


        toolbar.setListener(new CustomToolbar.ToolbarListener() {
            @Override
            public void onLeftBack() {
                finish();
            }

            @Override
            public void onRightBack() {

            }
        });

        if (!isSuccess) {
            resultIv.setBackgroundResource(R.mipmap.auth_defeated);
            resultTv.setText("认证失败");
            noticeTv.setText("请确认你提交的信息是否正确！");
        }
    }




    @OnClick({R.id.back_tv})
    public void onViewClicked(View view) {
            switch (view.getId()){
                case R.id.back_tv:
                    if(!isSuccess){
                        Intent intent = new Intent(AuthResultActivity.this,AuthResultActivity.class);

                        intent.putExtra("type",true);
                        startActivity(intent);
                    }else {
                        Intent intent = new Intent(AuthResultActivity.this,HasAndNoAuthActivity.class);
                        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        intent.putExtra("type",true);
                        startActivity(intent);
                    }
                    break;
            }
    }
}
